// Parse a JS url and return a string of the body
var snarf =  function(url) {
	var lastInd = content.location.href.lastIndexOf('/');
	var baseUrl = (lastInd > 0) ?
		content.location.href.substring(0,lastInd) :
		content.location.href;
		
	var req = new XMLHttpRequest();

	// TODO: need a better way to determine if the JS url is relative.
	if (url.indexOf('://') === -1) {
	  url = baseUrl + '/' + url;
	}
	req.open('GET', url, false);
	req.send(null);
	if (req.status !== 200) {
	  throw new Error("Error loading " + url);
	}
	return req.responseText;
}
// Load and execute the specified JS url
var loadExternalScript = function(url) {
	Narcissus.interpreter.evaluate(snarf(url), url, 1);
}